package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 功能异常枚举
 * <p>
 * Created by chenwei on 2017/6/21.
 */
public enum FuncitonExceptionEnum implements CustomExceptionCode {

    FUNCTION_NOT_ID(600, "功能id为空", 900),
    FUNCTION_NAME(600, "功能id为空", 900),
    FUNCTION_NOT_MSG(601, "功能不存在", 900),
    MODIFLY_FUNCTION_ERROR(601, "该功能已存在", 900),
    FUNCTION_QUERY_ERROR(602, "查询错误", 900),
    FUNCTION_SAVE_ERROR(602, "插入错误", 900),
    FUNCTION_UPDATE_ERROR(602, "更新错误", 900),
    FUNCTION_DELETE_ERROR(602,"删除SQL异常",900),
    FUNCTION_DELETE_NODE_ERROR(603,"该节点有子节点",900),
    FUNCTION_STATUS_ERROR(604,"该功能已经被分配，不能禁用",900)

    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    FuncitonExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }


    public static FuncitonExceptionEnum getEnumByCode(Integer code){
        for(FuncitonExceptionEnum funcitonExceptionEnum : FuncitonExceptionEnum.values()){
            if(code.equals( funcitonExceptionEnum.getCode())){
                return funcitonExceptionEnum;
            }
        }
        return null;
    }

}
